import { customRequest } from "../request/custom";
import { get, put,del,patch } from "../request/request";

/**
 * 根据ID获取用户信息
 * @param id 
 * @param callback 
 */
export const fetchUserInfo = async (id:string, callback?: () => void | boolean) => {
  return customRequest(() => get(`/api/user/${id}`, ), callback);
};


// ///////// 关注模块  ////////
/**
 * 关注
 * @param id 用户id
 * @param callback 
 */
export const fetchAddFollowing = async (id:string, callback?: () => void | boolean) => {
  return customRequest(() => put(`/api/user/following/${id}`), callback);
};

/**
 * 取消关注
 * @param id 用户id
 * @param callback 
 */
export const fetchUnFollowing = async (id:string, callback?: () => void | boolean) => {
  return customRequest(() => del(`/api/user/unfollowing/${id}`), callback);
};

/**
 * 获取关注列表
 * @param id 
 * @param callback 
 */
export const fetchFollowingList = (
  id: string,
  callback?: () => void | boolean
) => {
  return customRequest(
    () => get(`/api/user/${id}/followingList`),
    callback
  );
};

/**
 * 获取粉丝列表
 * @param id 
 * @param callback 
 */
export const fetchFansList = async (id: string, callback?: () => void | boolean) => {
  return customRequest(() => get(`/api/user/${id}/fansList`), callback);
};


// ///// 点赞列表 /////
/**
 * 获取我的点赞帖子列表
 * @param callback 
 */
export const fetchLikingTopicList = async (callback?: () => void | boolean) => {
  return customRequest(() => get(`/api/user/my/likingTopic`), callback);
};


// ///// 收藏列表 /////
/**
 * 获取我的收藏列表
 * @param callback 
 */
export const fetchCollectingTopicList = async (callback?: () => void | boolean) => {
  return customRequest(() => get(`/api/user/my/collectingTopic`), callback);
};
/**
 * 获取指定用户收藏列表
 * @param id 
 * @param callback 
 */
export const fetchUserCollectingTopicList = async (id:string,callback?: () => void | boolean) => {
  return customRequest(() => get(`/api/user/collectingTopic/${id}`), callback);
};



// ///// 头像图片 /////
/**
 * 获取头像图片列表
 * @param callback 
 */
export const fetchAvatarList = async (callback?: () => void | boolean) => {
  return customRequest(() => get("/api/info/avatar"), callback);
};

/**
 * 修改用户信息
 * @param formData 
 * @param callback 
 */
export const fetchPatchUserInfo = async (
  formData: object,
  callback?: () => void | boolean
) => {
  return customRequest(() => patch("/api/user/my/details", formData), callback);
};
